Skip to main content

groovy.lang.MissingPropertyException: No such property: Missing for class: Script3

Today I pulled a colleague's code, and upon startup I found an error that dataSource could not be instantiated. My first impression was that there was something wrong with the database configuration, and I spent a long time troubleshooting it. It turns out that the protagonist is Missing for class: Script3

......

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is groovy.lang.MissingPropertyException: No such property: Missing for class: Script3
Caused by: groovy.lang.MissingPropertyException: No such property: Missing for class: Script3
Possible solutions: binding
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
at Script3.run(Script3.groovy:1)
at org.apache.shardingsphere.core.util.InlineExpressionParser.evaluate(InlineExpressionParser.java:109)
at org.apache.shardingsphere.core.util.InlineExpressionParser.evaluate(InlineExpressionParser.java:96)
at org.apache.shardingsphere.core.util.InlineExpressionParser.splitAndEvaluate(InlineExpressionParser.java:74)
at org.apache.shardingsphere.core.rule.TableRule.<init>(TableRule.java:99)
at org.apache.shardingsphere.core.rule.ShardingRule.createTableRules(ShardingRule.java:95)
at org.apache.shardingsphere.core.rule.ShardingRule.<init>(ShardingRule.java:81)
at org.apache.shardingsphere.shardingjdbc.api.ShardingDataSourceFactory.createDataSource(ShardingDataSourceFactory.java:50)
at org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration.dataSource(SpringBootConfiguration.java:95)
at org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration$$EnhancerBySpringCGLIB$$80a7ec27.CGLIB$dataSource$0(<generated>)
at org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration$$EnhancerBySpringCGLIB$$80a7ec27$$FastClassBySpringCGLIB$$ec6a3296.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration$$EnhancerBySpringCGLIB$$80a7ec27.dataSource(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 38 more

Click in and take a look, and find that there is a script.run() method. Make a breakpoint and

restart it

I find this ds0. Isn’t this the database name I configured? Let’s check it out. Sure enough

it is. Let’s

let it go again, and suddenly I find something strange.

As expected, the release immediately reported an error. After realizing it, I quickly checked the configuration file and database configuration strategy.

Sure enough, there was something strange. I deleted it and restarted.